<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/4/16
 * Time: 10:51
 */

namespace app\common\validate;


use think\Validate;

class Manager extends Validate
{
    protected $rule = [ // 定义验证规则
        'user_id|用户id' => 'require|number',
        'username|账号' => 'require|unique:SysUser',
        'password|密码' => 'require',
        'phone|手机号' => 'require|regex:^1\d{10}|unique:SysUser',
        'true_name|用户名' => 'require',
        // 'user_type|用户身份' => 'require',
        // 'company_id|所属公司' => 'requireif:auth_type,2|gt:0',
    ];

    protected $message = [ // 定义验证提示
        'company_id.gt'=>'所属公司必填'
    ];

    protected $scene = [ // 定义验证场景
        'save' => ['username', 'phone', 'true_name'],
        'add' => ['username','password','user_type'],
        'update' => ['username.unique=>SysUser,user_id^username','user_type'],
        'phone' => ['phone'],
    ];
}